<template name="sendcar">
	<!--组织移出、组织移入列表 -->
	<view class="mypage">
		<!-- <dcustom bgColor="bg-blue" :isBack="true" :isArrow="true">
			<block slot="content">{{ title }}</block>
			<block slot="right">
				<view class="nav-right-wrap text-xl" @click="openDetailDataList(0)">
					<text class='cuIcon-roundadd'></text>
				</view>
			</block>
		</dcustom> -->

		<view class="cu-bar search bg-white">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input type="text" v-model="keyword" placeholder="输入单号" />
			</view>
			<view class="action">
				<button class="cu-btn bg-blue shadow-blur round">搜索</button>
			</view>
		</view>

		<view class="card-list-wrapper">
			<view class="card-list-row radius shadow-warp bg-white margin-top" v-for="(item,index) in planList"
				:key="index">

				<view class="flex-just-between bottom-border top-wrap">
					<text class="text-blue text-bold">{{ label01 }}：{{ item.BILLNO }}</text>
					<view class="cu-capsule radius">
						<view class='cu-tag bg-blue sm'>
							<text class='cuIcon-medal'></text>
						</view>
						<view class="cu-tag line-brown sm">
							{{ index+1}}
						</view>
					</view>
				</view>

				<view class="card-list-row-1">
					<text class="cuIcon-title text-red"></text>
					<text class="card-label text-black">集团：</text>
					<text>{{ item.GROUPNAME || '' }}</text>
				</view>
				<view v-if="type=='M1020'">
					<view class="card-list-row-1">
						<text class="cuIcon-title text-red"></text>
						<text class="card-label text-black">组织：</text>
						<text>{{ item.ORGNAME || '' }}</text>
					</view>

					<view class="card-list-row-1">
						<text class="cuIcon-title text-green"></text>
						<text class="card-label text-black">仓库：</text>
						<text>{{ item.STORENAME || '' }}</text>
					</view>
					<view class="card-list-row-1">
						<text class="cuIcon-title text-blue"></text>
						<text class="card-label text-black">移位人：</text>
						<text>{{ item.MOVER || '' }}</text>
					</view>
				</view>
				<view v-if="type=='M1021'">
					<view class="card-list-row-1">
						<text class="cuIcon-title text-red"></text>
						<text class="card-label text-black">移出组织：</text>
						<text>{{ item.ORGNAME || '' }}</text>
					</view>

					<view class="card-list-row-1">
						<text class="cuIcon-title text-green"></text>
						<text class="card-label text-black">移出仓库：</text>
						<text>{{ item.STORENAME || '' }}</text>
					</view>
					<view class="card-list-row-1">
						<text class="cuIcon-title text-red"></text>
						<text class="card-label text-black">移入组织：</text>
						<text>{{ item.INORGNAME || '' }}</text>
					</view>
					<view class="card-list-row-1">
						<text class="cuIcon-title text-green"></text>
						<text class="card-label text-black">移入仓库：</text>
						<text>{{ item.INSTORENAME || '' }}</text>
					</view>
					<view class="card-list-row-1">
						<text class="cuIcon-title text-blue"></text>
						<text class="card-label text-black">移入人：</text>
						<text>{{ item.MOVER || '' }}</text>
					</view>
				</view>

				<view class="card-list-row-1">
					<text class="cuIcon-title text-blue"></text>
					<text class="card-label text-black">制单人：</text>
					<text>{{ item.BILLMAKER || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-gray"></text>
					<text class="card-label text-black">日期：</text>
					<text>{{ item.BILLDATE || '' }}</text>
				</view>
			</view>

		</view>

	</view>

</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import api from '@/common/api.js'
	let _self, page = 1,
		total = 1,
		originalTitle, type, listType = 1;

	export default {
		computed: mapState(['userInfo', 'baseUrl']),
		data() {
			return {
				title: '列表',
				planList: [],
				type: '',
				label01: '订单'
			};
		},
		onLoad(params) {

			var datalist = params.n;

			var t = datalist.split(",");

			_self = this;
			_self.title = t[0] + '列表';
			/* 	console.log(_self.title);
				console.log(datalist); */
			originalTitle = t[0] + '列表'
			type = params.mt
			page = 1;
			total = 1;
			_self.type = t[1];
			/* 	console.log(params) */
			switch (params.mt) {
				case "M1017":
					query.category = 'BILLNO';
					_self.label01 = '单据编号'
					break;
				default:
					break;
			}
			// url = params.t == "M1001"? api.apiPublic.M1001List: api.apiPublic.M1003List
			this.getNewsList(_self.type);
			// console.log(params);

		},
		//下拉刷新
		onPullDownRefresh: function() {
			// 重置分页及数据
			page = 1;
			total = 1;
			this.getNewsList();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
			uni.showToast({
				"title": "数据已刷新",
				icon: "none"
			});
		},
		// 加载更多
		onReachBottom: function() {
			this.getNewsList();
		},
		onNavigationBarButtonTap() {
			this.openDetailDataList(0)
		},
		methods: {
			getNewsList(int) {
				console.log(int);
				if (page > total) {
					return uni.showToast({
						icon: 'none',
						title: '没有数据了。'
					})
				}

				let query = {};

				if (int == "M1020") {
					query = {
						"category": "",
						"page": 1,
						"rows": 5,
						"sidx": "",
						"sord": "",
						"queryJson": {
							BTCATEGORY: 3,
							MOVETYPE: 0
						},
						"userId": "",
						"account": "admin"
					}
				} else if (int == 'M1021') {
					query = {
						"category": "",
						"page": 1,
						"rows": 5,
						"sidx": "",
						"sord": "",
						"queryJson": {
							BTCATEGORY: 3,
							MOVETYPE: 1
						},
						"userId": "",
						"account": "admin"
					}
				}
				query.page = page;
				/* 	 console.log(listType);
					 console.log(query);
					 console.log(_self.baseUrl + api.apiPublic.GetMoveList); */
				this.axios({
					url: api.apiPublic.GetMoveList,
					data: query,
					isLoading: 1
				}).then(res => {
					let {
						Result
					} = res;
					if (page == 1) {
						_self.planList = res.rows
						_self.title = originalTitle + '(' + res.records + ')'
					} else {
						_self.planList = _self.planList.concat(res.rows)
					}
					total = res.total
					page++
				})
			},
			openDetailDataList: function(e) {
				/* 	 console.log(e);
					console.log(_self.type); */
				uni.navigateTo({
					url: '/pages/tab04/ApplicationList4?type=' + _self.type
				})
			}
		}
	}
</script>

<style scoped>
	.card-list-wrapper {
		width: 710upx;
		height: 100upx;
		margin: 0 auto;
	}

	.card-list-row {
		padding: 20upx;
	}

	.card-list-row-1 {
		padding: 10upx 0;
	}

	.card-label {
		display: inline-block;
		width: 150upx;
	}

	.top-border {
		border-top: 1upx solid rgba(0, 0, 0, .1);
	}

	.top-wrap {
		padding-bottom: 20upx;
		margin-bottom: 20upx;
	}

	.bottom-border {
		border-bottom: 1upx solid rgba(0, 0, 0, .1);
	}

	.btn-wrap {
		padding-top: 20upx;
	}
</style>
